<!-- 登录 -->
<template>
	<form>
		<view class="selogin-view">
			<text class="selogin">登录</text>
		</view>
		<view class="input-view">
			<input class="input" type="text" placeholder="请输入登录账号" name="phoneValue" v-model="phoneValue" />
		</view>
		<view class="input-view">
			<input class="input" type="password" placeholder="密码"  v-model="passwordValue" name="passwordValue" />
		</view>
		<button class="button-view" @click="login">登录</button>
	</form>
</template>

<script>
	export default {
		data() {
			return {
				'phoneValue': "",
				'passwordValue': "",
			}
		},
		onLoad() {
			// uni.removeStorage({
			//     key: '',
			//     success: function (res) {
			//         console.log('success');
			//     }
			// });
		},
		methods: {
			login(e){
				console.log("登录账号:"+ this.phoneValue + ';密码:' + this.passwordValue);
								uni.request({
								    url:this.$serverUrl + '/app/hospital/user/pwLogin', //仅为示例，并非真实接口地址。
									data: {
										'phone': this.phoneValue,
										'password': this.passwordValue
								    },
									method:"POST",
									header:{
										'content-type': "application/json",
										'content-type': "application/x-www-form-urlencoded"
									}, 
								    success: (res) => {
								         console.log(res.data.data.token);
								    	if(res.data.code==0){
								    		uni.setStorageSync('token', res.data.data.token);
											uni.setStorageSync('info', res.data.data.user);
								    		uni.switchTab({
								    			url:'../situationmanage/situation'
								    		});
								    	}else{
								    		uni.showToast({
								    		    title: res.data.msg,
								    		    duration: 2000
								    		});
								    	}
								    }
				});
			}
		}
	}

</script>
<style>
	/* 头部登录 */
	.selogin-view{
		padding-top: 170upx;
		padding-bottom: 30upx;
		padding-left: 25upx;
	}
	.selogin{
		font-size: 48upx;
		color: #333333;
		font-weight: bold;
		text-align: center;
	}

/* 账号密码输入框 */
.input-view {
	display: flex;
	border-bottom-style: solid;
	border-bottom-width: 2upx;
	border-bottom-color:#007AFF;
	background-color: #fff;
	flex-direction: row;
	width: 700upx;
	margin: auto;
	padding: 25upx 3upx;
	box-sizing: border-box;
}
	/* 忘记密码 */
	.wpsd-view{
		padding:40upx 25upx ;
		
	}
	.wpsd{
		color: #007AFF;
	}
/* 登录按钮 */
.button-view {
	width: 520upx;
	margin-top:50upx;
	background-color:#007AFF;
	color: #FFFFFF;
	border-radius: 100upx;
}
</style>
